home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F32960_testSomeAllTrue.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2001-10-26  |  2.9 KB  |  103 lines

  1. <xsl:stylesheet version="1.0" 
  2. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:myPredicate="myPredicate"
  4. >
  5.   <xsl:import href="allTrue.xsl"/>
  6.   <xsl:import href="someTrue.xsl"/>
  7.   <xsl:import href="someTrueP.xsl"/>
  8.   <xsl:import href="allTrueP.xsl"/>
  9.  
  10.   <myPredicate:myPredicate/>
  11.   <xsl:variable name="vPredicate" select="document('')/*/myPredicate:*[1]" />
  12.     
  13.   <xsl:output omit-xml-declaration="yes"/>
  14.   
  15.   <xsl:template match="/">
  16.     <xsl:variable name="allTrue">
  17.         <xsl:call-template name="allTrue">
  18.           <xsl:with-param name="pList" select="/*/*"/>
  19.         </xsl:call-template>
  20.     </xsl:variable>
  21.     
  22.     <xsl:if test="not(string($allTrue))">
  23.       <xsl:text>Not </xsl:text>
  24.     </xsl:if>
  25.     <xsl:value-of select="'all nodes contents are true in:'"/>
  26.     <xsl:text> </xsl:text>
  27.     <xsl:copy-of select="/*/*"/>
  28.  
  29.     <xsl:text> </xsl:text>
  30.        
  31.     <xsl:variable name="someTrue">
  32.         <xsl:call-template name="someTrue">
  33.           <xsl:with-param name="pList" select="/*/*"/>
  34.         </xsl:call-template>
  35.     </xsl:variable>
  36.     
  37.     <xsl:choose>
  38.         <xsl:when test="not(string($someTrue))">
  39.           <xsl:text>None are true</xsl:text>
  40.         </xsl:when>
  41.         <xsl:otherwise>
  42.           <xsl:text>Some are true</xsl:text>
  43.         </xsl:otherwise>
  44.     </xsl:choose>
  45.     
  46.     <xsl:text> </xsl:text>
  47.     <xsl:copy-of select="/*/*"/>
  48.     
  49.     <xsl:text> </xsl:text>
  50.    
  51.     <xsl:variable name="someTrueP">
  52.         <xsl:call-template name="someTrueP">
  53.           <xsl:with-param name="pList" select="/*/*"/>
  54.           <xsl:with-param name="pPredicate" select="$vPredicate"/>
  55.         </xsl:call-template>
  56.     </xsl:variable>
  57.     
  58.     <xsl:choose>
  59.         <xsl:when test="not(string($someTrueP))">
  60.           <xsl:text>None hold true for: </xsl:text>
  61.         </xsl:when>
  62.         <xsl:otherwise>
  63.           <xsl:text>Some are true for:</xsl:text>
  64.         </xsl:otherwise>
  65.     </xsl:choose>
  66.     
  67.     <xsl:text>(= 'x') in: </xsl:text>
  68.     
  69.     <xsl:text> </xsl:text>
  70.     <xsl:copy-of select="/*/*"/>
  71.      <xsl:text> </xsl:text>
  72.    
  73.     <xsl:variable name="allTrueP">
  74.         <xsl:call-template name="allTrueP">
  75.           <xsl:with-param name="pList" select="/*/*"/>
  76.           <xsl:with-param name="pPredicate" select="$vPredicate"/>
  77.         </xsl:call-template>
  78.     </xsl:variable>
  79.     
  80.     <xsl:choose>
  81.         <xsl:when test="not(string($allTrueP))">
  82.           <xsl:text>Not all hold true for: </xsl:text>
  83.         </xsl:when>
  84.         <xsl:otherwise>
  85.           <xsl:text>All hold true for:</xsl:text>
  86.         </xsl:otherwise>
  87.     </xsl:choose>
  88.     
  89.     <xsl:text>(= 'x') in: </xsl:text>
  90.     
  91.     <xsl:text> </xsl:text>
  92.     <xsl:copy-of select="/*/*"/>
  93.   
  94.   </xsl:template>
  95.   
  96.   <xsl:template name="myPredicate" match="*[namespace-uri()='myPredicate']">
  97.     <xsl:param name="arg1"/>
  98.     
  99.     <xsl:if test="$arg1 = 'x'">1</xsl:if>
  100.   </xsl:template>
  101. </xsl:stylesheet>
  102.  
  103.